// 后台注册邮箱正则校验
export const emailRegisterReg = /^[^@\s]+@([^@\s]+\.)+[^@\s]+$/
// 修复js部分特性缺陷时用到的正则

export const fixJsDefectReg = {
  json: {
    // 修复数字精度
    number_precision: {
      source: /: ?(\d{15,})/g,
      result: ':"$1"'
    },
    // 修复格式错误
    format_wrong: [
      {
        source: /\\\//g,
        result: '/'
      }
    ],
    // 安卓特性错误
    android_wrong: [
      {
        source: /\s/g,
        result: '&nbsp;'
      },
      {
        source: /\r/g,
        result: '\\r'
      },
      {
        source: /\n/g,
        result: '\\n'
      }
    ]
  }
}

export const appply_reg2replace = (
  v: string,
  regObject: {
    source: RegExp
    result: string
  }
) => v.replace(regObject.source, regObject.result)
